<?php

class Packages extends AppModel {
	public $name="Packages";
 // public $hasMany = 'PackagesItems';
	/*public $belongsTo ="Services"; 
     */
     public $hasMany = array(
      'PackagesItems' => array(
          'className' => 'PackagesItems',
          'foreignKey' => 'packages_id'                 
      )
    );

   public $validate = array(
   	'name'=>array(
    		'r0' => array(
          'rule'    => 'notEmpty',
          'message' => 'Nombre no puede ser vacio')
  )

	);

    public function beforeSave($options=array()){
        $date = date('Y-m-d', strtotime( $this->data['Packages']['expiration_date']));
        $this->data['Packages']['expiration_date']=$date; 
        $this->data['Packages']['total_service']=0;
         
        //var_dump($this->data);
        //$time->add(new DateInterval('PT' . $time_to . 'M'));
        //var_dump($time);
        return true;
    }

}